package com.ag.admin.dao;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

@Repository("LZMTbUserDAO")
public class TbUserDAO extends com.ag.dao.TbUserDAO {
	private static final Log log = LogFactory.getLog(TbUserDAO.class);
	private SessionFactory sessionFacotry;

	@Resource
	public void setSessionFacotry(SessionFactory sessionFacotry) {
		this.sessionFacotry = sessionFacotry;
	}

	@PostConstruct
	public void injectSessionFactory() {
		super.setSessionFactory(sessionFacotry);
	}

	public List find(String queryString) {
		log.debug("finding all instances");
		try {
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find failed", re);
			throw re;
		}
	}

	public List find(String queryString, Object value) {
		log.debug("finding all instances with option: " + value);
		try {
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find all instances with option failed", re);
			throw re;
		}
	}

	public List find(String queryString, Object[] value) {
		log.debug("finding all instances with option: " + value);
		try {
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find all instances with option failed", re);
			throw re;
		}
	}

}
